package com.xianxiaohui.generator;

import java.util.Map;
import java.util.Objects;

public class URLBuilder {
    private String scheme = "http";
    private int port = -1;
    private String domain = null;
    private String path = "/";
    private String username = null;
    private String password = null;
    private Map<String, String> query = null;

    public static URLBuilder builder() {
        return new URLBuilder();
    }

    public URLBuilder setScheme(String scheme) {
        this.scheme = Objects.requireNonNull(scheme);
        return this;
    }

    public URLBuilder setDomain(String domain) {
        this.domain = Objects.requireNonNull(domain);
        return this;
    }

    public URLBuilder setPath(String path) {
        this.path = Objects.requireNonNull(path);
        return this;
    }

    public URLBuilder setQuery(Map<String, String> query) {
        this.query = query;
        return this;
    }

    public String build() {
        return "URLBuilder{" +
                "scheme='" + scheme + '\'' +
                ", port=" + port +
                ", domain='" + domain + '\'' +
                ", path='" + path + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", query=" + query +
                '}';
    }


}
